package pl.perseus.dao;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import pl.perseus.model.User;

@Repository
public class UserDao extends BaseDao<User> implements IUserDao{
 
	
	public UserDao() {
		super("User");
	}

	@Override
	public User getById(Long id){
		Map<String, Object> map = new HashMap<String, Object>();
    	map.put("id", id);
        return queryForObject("getByIDUser", map);
	}
	
	@Override
    public User selectByLoginUser(String login) {
    	Map<String, Object> map = new HashMap<String, Object>();
    	map.put("login", login);
        return queryForObject("getByLoginUser", map);
    }
	
	@Override
	public User insertUser(User user){
		return insertBean("insertUser", user);
	}
	
	@Override
	public User updateUser(User user){
		return updateBean("updateUser", user);
	}
	
	@Override
	public void deleteUser(User u){
		delete("deleteUser", u);
	}
	
	@Override
	public List<User> getAllTeachers(){
		Map<String, Object> map = new HashMap<String, Object>();
    	map.put("active", true);
    	map.put("accountname", "User");
		return queryForList("getByActiveUserAccountname", map);
	}
	
	@Override
	public List<User> getTeachersForClasses(Long classesId){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("classesId", classesId);
		
		return queryForList("getTeachersForClasses", map);
	}
	
	@Override
	public List<User> getAllUsers(){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("active", true);
		
		return queryForList("getByActiveUser", map);
	}
	
 
}
